<?php
	//处理登录功能的
session_start();
include_once("init.php");
extract($_POST);
  if(!isset($sub)){
  	msg("请从表单提交","login.php");
  	exit;
  }
  $user=trim($user);
  $pwd=trim($pwd);
  if($user=="" || $pwd==""){
  	msg("用户名密码不能为空","login.php");
  	exit;
  }
switch($remb){
	case "no":
	$time=time()-1;
	break;
	case "day":
	$time=time()+3600*24;
	break;
	case "week":
	$time=time()+3600*24*7;
	break;
	case "month":
	$time=time()+3600*24*30;
	break;
}
//设置cookie
$res1=setcookie('user',$user,$time);
$res2=setcookie('pwd',$pwd,$time);
$res3=setcookie('remb',$remb,$time);
//将用户名存入session
$_SESSION['user']=$user;
if($res1&&$res2&&$res3){
	msg("登录成功","index.php");
}else{
	msg("登录失败","index.php");
}
?>